<template>
  <div class="view-item">
    <!-- 左边 -->
    <div class="view-left">
      <p class="view-title">{{ subject }}</p>
      <div class="view-tags">
        <span class="yellow-tag" v-if="articlePersonalCategoryName">{{
          articlePersonalCategoryName
        }}</span>
       
        <span v-if="tags.length" class="blue-tag">{{ tags[0].name}}</span>
      </div>
      <div class="view-info">
        {{ publishDate?.substring(0, 10) }} · {{ voteCount }}推荐 ·
        {{ viewCount }}阅读
      </div>
    </div>
    <!-- 右边 -->
    <div class="view-right">
      <img :src="`https://file.ituring.com.cn/SmallCover/${cover}`" alt="" />
    </div>
  </div>
</template>

<script>
export default {
  props: [
    "subject",
    "articlePersonalCategoryName",
    "tags",
    "publishDate",
    "voteCount",
    "viewCount",
    "imageKey",
  ],
  
  computed: {
    // 有的用户没有设置头像
    cover() {
      if (this.imageKey == null) {
        return "";
      } else {
        return this.imageKey;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.view-item {
  width: 345px;
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  .view-left {
    .view-title {
      color: var(--book-name-font-black);
      font-size: 16px;
      width: 289px;
      line-height: 21px;
      max-height: 42px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .view-tags {
      display: flex;
      margin-top: 8px;
      .yellow-tag {
        color: var(--yellow-tag-font-orange);
        background-color: var(--yellow-tag-bg-orange);
        border: 1px solid var(--yellow-tag-font-orange);
        font-size: 12px;
        line-height: 20px;
        padding: 0 10px;
        margin-right: 15px;
        //
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .blue-tag {
        color: var(--theme-blue);
        background-color: var(--blue-tag-bg-blue);
        font-size: 12px;
        line-height: 20px;
        padding: 2px 10px;
        border-top-right-radius: 10px;
        border-bottom-right-radius: 10px;
        margin-right: 10px;
        //
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .view-info {
      color: var(--more-font-grey);
      font-size: 14px;
      line-height: 23px;
      margin-top: 10px;
    }
  }
  .view-right {
    img {
      width: 36px;
      height: 36px;
      border-radius: 36px;
    }
  }
}
</style>